home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11285 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c,comp.lang.c++
  4. Subject: Re: Why is C faster than FORTRAN?
  5. Date: 13 Mar 1996 10:36:07 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4i74inINNnfj@keats.ugrad.cs.ubc.ca>
  8. References: <4hv2ho$d8t@news.interpath.net> <4i2c5e$t70@kiwi.futuris.net> <4i4poj$j7e@thorn.cc.usm.edu>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <4i4poj$j7e@thorn.cc.usm.edu>,
  12. Peter Sakalaukus <sakalauk@coam.usm.edu> wrote:
  13. >I have two programs, FORTRAN and C. They both use the same algorithm to
  14. >manipulate numeric data. The larger the data file though, the faster the
  15. >C version is, (in relation to the FORTARN program). I am running on a UNIX
  16. >platform. 
  17.  
  18. If it is truly the same algorithm, and the C implementation is faster, than
  19. there will simply be a constant-factor difference in the running times, which
  20. makes one appear faster as the data set grows. If you find the ratio of their
  21. running times, you may discover that it is roughly constant.
  22.  
  23. >My question is: what is the reason that C is so much quicker? Is C normally
  24. >faster than FORTRAN?
  25.  
  26. The C compiler probably has better optimization, since it is the primary
  27. development language on the workstation you are using. It's hard to say without
  28. seeing both programs to see how they use the language features.
  29.  
  30. You said that they work on a data file, which indicates that the C buffered I/O
  31. library may be responsible for the difference. Have you measured the
  32. user/system CPU times or just the elapsed wall clock time?
  33. -- 
  34.  
  35.